﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MeTalker.Aide.data;

namespace MeTalker.Aide.Forms
{
    internal partial class frmTemplate : MeForm
    {
        int id = 0;
        private frmTemplate()
        {
            InitializeComponent();
        }

        public frmTemplate(string title, int Id)
            : this()
        {
            id = Id;
            lblFor.Text = string.Format(lblFor.Text, title);
            cboMenu.DisplayMember = "Title";
            cboMenu.ValueMember = "Id";
            cboMenu.DataSource = (from temp in DataFactory.Menus.Nodes where temp.Id != id select temp).ToList();
        }

        private void btnCancle_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            menu = cboMenu.SelectedItem as MessageNode;
            if (menu != null)
            {
                DialogResult result = MeMessageBox.ShowQuestion("确定要" + lblTip.Text + lblFor.Text);
                if (result == DialogResult.Yes)
                {
                    DialogResult = DialogResult.Yes;
                    this.Close();
                }
            }
        }
        MessageNode menu;
        internal MessageNode NavigationMenu
        {
            get { return menu; }
        }
        private void cboMenu_SelectedIndexChanged(object sender, EventArgs e)
        {
            MessageNode nodes = cboMenu.SelectedItem as MessageNode;
            if (nodes != null)
            {
                lblTip.Text = string.Format("将菜单[{0}]当作模板", nodes.Title);
            }
        }
    }
}